﻿using System;
using System.IO;
using System.Net;
using System.Reflection;
using System.Security;
using System.Security.Policy;
using System.Security.Permissions;

class Program
{
    static void Main()
    {

               
        string pluginFolder = AppDomain.CurrentDomain.BaseDirectory;
        string plugInPath = Path.Combine(pluginFolder, "plugin.exe");

        PermissionSet ps = new PermissionSet(PermissionState.None);

        ps.AddPermission
          (new SecurityPermission(SecurityPermissionFlag.Execution));


        ps.AddPermission (new FileIOPermission(FileIOPermissionAccess.PathDiscovery |
                             FileIOPermissionAccess.Read, plugInPath));


        ps.AddPermission(new UIPermission(PermissionState.Unrestricted));



        AppDomainSetup setup = AppDomain.CurrentDomain.SetupInformation;
        AppDomain sandbox = AppDomain.CreateDomain("sbox", null, setup, ps);
        sandbox.ExecuteAssembly(plugInPath);
        AppDomain.Unload(sandbox);
    }
}